package com.si.sea_island.mapper;

import com.si.sea_island.pojo.VerifyDB;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

@Component
public interface VerifyMapper {

    @Insert("insert into si_verify (uid,token,time,type)values(#{userId},#{token},#{time},#{type})")
    int saveToken(int userId, String token, String time, String type);

    @Update("update si_verify set token=#{token},time=#{nowTime} where uid=#{userId} and type=#{type}")
    int updateToken(int userId, String token, String nowTime, String type);

    @Select("select token from si_verify where uid=#{uid} and type=#{type}")
    String getVerifyDBById(int uid, String type);

    @Select("select * from si_verify where uid=#{uid} and type=#{type}")
    VerifyDB getVerifyDB(int uid, String type);

    @Update("update si_verify set time=#{nowTime} where uid=#{userId} and type=#{type}")
    int updateTime(int userId, String nowTime, int type);

    @Update("update si_verify set token='' where uid=#{userId} and type=#{type}")
    int logOut(int userId, String type);

    @Select("select * from si_verify where token=#{token}")
    VerifyDB getVerifyDBByToken(String token);

}
